﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Shop.Common
{
    public class ReturnValue
    {
        public static Dictionary<string, object> Get(string message, bool bret)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            int result;
            if (bret) { result = 1; }
            else { result = -1; }
            dic.Add("result", result);
            dic.Add("resultdetail", message);
            return dic;
        }
        public static Dictionary<string, object> ErrAction()
        {
            Dictionary<string, object> dic  = new Dictionary<string, object>();
            dic.Add("result", -1);
            dic.Add("resultdetail", "ErrAction");
            return dic;
        }
        public static Dictionary<string, object> Get(string message, List<Dictionary<string, object>> list, bool bret)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            int result;
            if (bret) { result = 1; }
            else { result = -1; }
            dic.Add("result", result);
            dic.Add("resultdetail", message);
            dic.Add("details", list);
            return dic;
        }

        public static Dictionary<string, object> Get<T>(string message, List<T> list, bool bret)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            int result;
            if (bret) { result = 1; }
            else { result = -1; }
            dic.Add("result", result);
            dic.Add("resultdetail", message);
            dic.Add("rows", list.Count);
            dic.Add("details", list);
            return dic;
        }

    }
}